//
//  AYSDisclaimerViewController.m
//  AiYingShiProject
//
//  Created by lanou on 15/11/2.
//  Copyright (c) 2015年 李晓理. All rights reserved.
//

#import "AYSDisclaimerViewController.h"

@interface AYSDisclaimerViewController ()<UITextViewDelegate>


@property (nonatomic,strong) UITextField *phoneTextFiled;
@property (nonatomic,strong) UIButton *tickingButton;
@property (nonatomic,strong) UITextView *mainTextView;
@end

@implementation AYSDisclaimerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.titleLabel.text = @"意见反馈";
    
    _mainTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 75, SCREEN_WIDTH - 20, SCREEN_HEIGHT / 4)];
    _mainTextView.layer.borderColor = UIColor.grayColor.CGColor;
    _mainTextView.layer.masksToBounds = YES;
    _mainTextView.layer.borderWidth = 0.5;
    _mainTextView.layer.cornerRadius = 6;
    _mainTextView.delegate = self;
    _mainTextView.text = @"请在这里填写您的反馈，我们会认真听取您的意见，在您的关注下变的更好";
    _mainTextView.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:_mainTextView];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, SCREEN_HEIGHT / 4 + 95, SCREEN_WIDTH - 20, 20)];
    label.text = @"请留下您的联系方式，便于我们联系到您";
    label.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:label];
    
    _phoneTextFiled = [[UITextField alloc] initWithFrame:CGRectMake(10, SCREEN_HEIGHT / 4 + 95 + 20 , SCREEN_WIDTH - 20, 30)];
    _phoneTextFiled.borderStyle = UITextBorderStyleRoundedRect;
    _phoneTextFiled.placeholder = @"QQ/邮箱/手机任选其一";
    [_phoneTextFiled setValue:[UIFont boldSystemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
    [self.view addSubview:_phoneTextFiled];
    
    _tickingButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _tickingButton.frame = CGRectMake(10, SCREEN_HEIGHT / 4 + 95 + 20 +50, SCREEN_WIDTH - 30, 40);
    _tickingButton.layer.masksToBounds = YES;
    _tickingButton.layer.cornerRadius = 10;
    _tickingButton.backgroundColor = [UIColor colorWithWhite:0.090 alpha:0.660];
    [_tickingButton setTitle:@"提交反馈" forState:(UIControlStateNormal)];
    [_tickingButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    [_tickingButton addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:_tickingButton];
}

// textView代理方法
- (void)textViewDidBeginEditing:(UITextView *)textView
{
    if ([textView.text isEqualToString:@"请在这里填写您的反馈，我们会认真听取您的意见，在您的关注下变的更好"])
    {
        textView.text = @"";
    }
}

- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView.text.length < 1)
    {
        textView.text = @"请在这里填写您的反馈，我们会认真听取您的意见，在您的关注下变的更好";
    }
}

- (void)clickButton:(UIButton *)button
{
    if (_mainTextView.text.length == 0 ||  [_mainTextView.text isEqualToString:@"请在这里填写您的反馈，我们会认真听取您的意见，在您的关注下变的更好"])
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"反馈意见不能为空" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"反馈成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
        [self.navigationController popViewControllerAnimated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
